<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function Student(name,age){
            this.name=name;  
            this.age=age;
         
        }
        var stu=new Student("张赫",40);
       
        //可以使用for...in循环遍历对象
        // for(var key in stu){
        //     // console.log(key);//属性名
        //     console.log(stu[key]);//属性值  stu["name"] stu['age']
        //     // console.log(stu.key);//不能使用这样的方式，会将key当成对象的属性名key
        // }

        var obj={
            name:"alice",
            age:20,
            sex:"女",
            weight:112,
            height:170
        };
        for(var index in obj){
            // console.log(index);//属性名
            // console.log(obj[index]);//属性值
            console.log(obj.key);//undefined
        }
        console.log("--------------------");

        // for...of不能用来遍历对象
        // for(var i of obj){
        //     console.log(i);
        // }

        var obj2={name:"cici"};
        obj2.name="璐璐";
        console.log(obj2);
    </script>
</head>
<body>
    
</body>
</html>